<script>
function page(page)
{
	$('#insure').html('<img style=\'margin-top:100px;\' src=\'images/loading.gif\' align="absmiddle"/>'); 
	$.get(
			'insure_ajax.php',
			{
				page:page,
				type:'<?=$_GET['type']?>',
				company:'<?=$_GET['company']?>'
			},
			function(data){
				$('#insure').html(data).hide().fadeIn('slow');
			},
			'html'
		);	
}
</script>
<? 
@session_start(); 
include("include/db_connect.php"); 
connect();
$sql="SET CHARACTER SET UTF8";   
query($sql); 
include "try_session_login.php";

$page = (isset($_GET['page']))? intval($_GET['page']) : 1;
$limit_end=20;

$limit_start = ($page-1)*$limit_end;

$send = "type=".$_GET['type'];

$sql = "select * from tb_insure where 1";
if($_GET['type']){
	$sql.= " and insure_type='".$_GET['type']."'";
}
if(is_numeric($_GET['company'])){
	$sql.=" and company_id = '".$_GET['company']."'";
}
$qr=select($sql. " LIMIT " . $limit_start. "," . $limit_end); 
$total=count($qr);
$rows = mysql_num_rows(mysql_query($sql));
$i=0;

?>

<a href="admin.php?page=insure_add" class="fg-button ui-state-default fg-button-icon-left ui-corner-all " ><span class="ui-icon ui-icon-plus"/>สร้าง</a>
<table border="1" align="center" cellpadding="3" cellspacing="0" style="border-collapse:collapse;" id="tbl_content" width="100%">
  <tr class="ui-widget-header" style="font-size:13px">
    <td rowspan="2" align="center" >บริษัท</td>
    <td rowspan="2" align="center" >ซ่อม</td>
    <td colspan="2" align="center" >รับผิดชอบบุคคลภายนอก</td>
    <td colspan="3" align="center" >ตัวรถเอาประกัน</td>
    <td colspan="3" align="center" >ความคุ้มครองตามเอกสารแนบท้าย</td>
    <td rowspan="2" align="center"  >ความรับผิดชอบ<br />
    ส่วนแรก</td>
    <td rowspan="2" align="center"  >รถฉุกเฉิน</td>
    <td rowspan="2" align="center"  >รับรถ</td>
    <td rowspan="2" align="center"  >ปีที่รับ</td>
    <td rowspan="2" align="center"  >ถ่ายรูป</td>
    <td rowspan="2" align="center"  >ที่นั่ง</td>
    <td rowspan="2" align="center"  >ราคาปกติ</td>
    <td rowspan="2" align="center" ไ width="60" >ตัวเลือก</td>
  </tr>
  <tr class="ui-widget-header" style="font-size:13px">
    <td align="center" >ทรัพย์สิน</td>
    <td align="center" >บุคคล</td>
    <td align="center" >สูญหาย/<br />
    ไฟไหม</td>
    <td align="center" >การชน</td>
    <td align="center" >น้ำท่วม</td>
    <td align="center" >เสียชีวิต <br />
      สูญเสียอวัยวะ <br />
    ทุพพลภาพถาวร</td>
    <td align="center"  >ค่ารักษาพยาบาล</td>
    <td align="center"  >ประกันตัวผู้ขับขี่</td>
  </tr>
  <?php
  
if($total > 0){ 
	while($i<count($qr)){ 
	$rs=$qr[$i];
	if($bg=='#ffffff'){$bg='#f2f2f2';}else{$bg='#fff';}
	
?>
  <tr  bgcolor="<?=$bg?>"  onmouseout="this.className=''" onmouseover="this.className='ui-state-error'" id="list<?=$rs['id']?>" style="font-size:13px">
    <td align="center" ><?=$rs['b']?></td>
    <td align="center" ><?=$rs['f']?></td>
    <td align="center" ><?=number_format($rs['t'])?></td>
    <td align="center" ><?=number_format($rs['r'])?></td>
    <td align="center" ><?=number_format($rs['i'])?></td>
    <td align="center" ><?=number_format($rs['h'])?></td>
    <td align="center" ><?=number_format($rs['z'])?></td>
    <td align="center" ><?=number_format($rs['u'])?></td>
    <td align="center"><?=number_format($rs['v'])?></td>
    <td align="center"><?=number_format($rs['w'])?></td>
    <td align="center"><?=number_format($rs['l'])?></td>
    <td align="center"><?=$rs['m']?></td>
    <td align="center"><?=$rs['n']?></td>
    <td align="center" valign="middle"><?=$rs['o']?></td>
    <td align="center" valign="middle"><?=$rs['p']?></td>
    <td align="center" valign="middle"><?=$rs['q']?></td>
    <td align="center" valign="middle"><?=number_format($rs['j'],2)?></td>
    <td align="center" valign="middle">
     	<ul id="icons" class="ui-widget ui-helper-clearfix">
        	<li class="ui-state-default ui-corner-all" title="แก้ไข" onclick="window.location='admin.php?page=insure_add&id=<?=$rs['id']?>'"><span class="ui-icon ui-icon-wrench"></span></li>
            <li class="ui-state-default ui-corner-all" title="ลบข้อมูล" onclick="DeleteData('<?=$rs['id']?>');"><span class="ui-icon ui-icon-trash"></span></li>
         </ul>
     </td>
  </tr>
  <?php 
  $i++;
	}//end while//
}//end if($total > 0)//
  ?>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30">
	<?php if(($rows/$limit_end) > 1){ 
		if($_GET[type]<>''){
			echo "\n<div>" . page_navi5($page, $limit_end, 4, $rows, $send,"mynavic","mynavi") . " </div>";
		}else{
			echo "\n<div>" . page_navi2($page, $limit_end, 4, $rows, $send,"mynavic","mynavi") . " </div>";
		}
	}
	?></td>
  </tr>
</table>